
#ifndef __CONTROL_H__
#define __CONTROL_H__

#include <stack>
#include "imagectrl.h"
#include "picbox.h"
#include "titlebar.h"

class Control
{
	struct Message
	{
		HWND hwnd;
		UINT message;
		WPARAM wParam;
		LPARAM lParam;
	};
public:
	Control(void);
	virtual ~Control(void);
	void Init();
	void UnInit();
	LRESULT DispatchMessage(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

protected:
	PicBox m_picbox;
	TitleBar m_titlebar;
	HDC m_memdc;
	HBITMAP m_membitmap;
	HBRUSH m_brush;
	std::stack<Message> m_messageStack;

	void OnPaint();
	void OnMouseMove(UINT nFlags, POINT point);
	void OnLButtonDown(UINT nFlags, POINT point);
	void OnLButtonUp(UINT nFlags, POINT point);
	void OnSize(UINT nType, int cx, int cy);

	void CreateMemBitmap();
	void FreeMemBitmap();
	POINT LparamToPoint(LPARAM lParam);
	void Draw();
	void Layout();
	LRESULT DefaultMessageProcess();

};

#endif //__CONTROL_H__
